class Solution(object):
    """reverse words in a string"""
    def reverseWords(self, s):
        s = s[::-1]
        lst = s.split()
        for i in range(len(lst)):
            lst[i] = lst[i][::-1]
        s = ' '.join(lst)
        return s

# test
ss = Solution()
str = 'this is a test'
print ss.reverseWords(str)
